package com.control;

/**
 * Created by geange on 16-12-16.
 */
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.beans.BookBean;
import com.beans.BookDAO;
public class BookQueryServlet extends HttpServlet{
    public void doPost(HttpServletRequest request,HttpServletResponse response)
            throws ServletException,IOException{
        String bookid = request.getParameter("bookid");
        BookDAO bookdao = new BookDAO();
        BookBean book = bookdao.searchBook(bookid);
        if(book!=null){
            request.getSession().setAttribute("book", book);
            BookBean bookBean = (BookBean) request.getSession().getAttribute("book");
            System.err.println(bookBean.getBookid()+" "+bookBean.getTitle()+" "+bookBean.getAuthor()+" "+bookBean.getPublisher()+" "+bookBean.getPrice());
            RequestDispatcher view = request.getRequestDispatcher("/display.jsp");
            view.forward(request, response);
        }else{
            RequestDispatcher view = request.getRequestDispatcher("/errorPage.jsp");
            view.forward(request, response);
        }
    }
}
